/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author WenYong
 */
@Entity(name = "UnstructuredContentPanel")
public class UnstructuredContentPanelEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long unstructuredContentPanelId;
    private String panelName;
    @ManyToOne
    private UnstructuredContentPageEntity unstructuredContentPage;
    @OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true, mappedBy = "unstructuredContentPanel")
    private List<UnstructuredContentElementEntity> unstructuredContentElement = new ArrayList<UnstructuredContentElementEntity>();

    public UnstructuredContentPanelEntity() {
    }

    public UnstructuredContentPanelEntity(Long unstructuredContentPanelId, String panelName, List<UnstructuredContentElementEntity> unstructuredContentElement) {
        this.unstructuredContentPanelId = unstructuredContentPanelId;
        this.panelName = panelName;
        this.unstructuredContentElement = unstructuredContentElement;
    }

    public Long getUnstructuredContentPanelId() {
        return unstructuredContentPanelId;
    }

    public void setUnstructuredContentPanelId(Long unstructuredContentPanelId) {
        this.unstructuredContentPanelId = unstructuredContentPanelId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (unstructuredContentPanelId != null ? unstructuredContentPanelId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the unstructuredContentPanelId fields are not set
        if (!(object instanceof UnstructuredContentPanelEntity)) {
            return false;
        }
        UnstructuredContentPanelEntity other = (UnstructuredContentPanelEntity) object;
        if ((this.unstructuredContentPanelId == null && other.unstructuredContentPanelId != null) || (this.unstructuredContentPanelId != null && !this.unstructuredContentPanelId.equals(other.unstructuredContentPanelId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.UnstructuredContentPanelEntity[ id=" + unstructuredContentPanelId + " ]";
    }

    public List<UnstructuredContentElementEntity> getUnstructuredContentElement() {
        return unstructuredContentElement;
    }

    public void setUnstructuredContentElement(List<UnstructuredContentElementEntity> unstructuredContentElement) {
        this.unstructuredContentElement = unstructuredContentElement;
    }

    public String getPanelName() {
        return panelName;
    }

    public void setPanelName(String panelName) {
        this.panelName = panelName;
    }

    /**
     * @return the unstructuredContentPageEntity
     */
    public UnstructuredContentPageEntity getUnstructuredContentPage() {
        return unstructuredContentPage;
    }

    /**
     * @param unstructuredContentPageEntity the unstructuredContentPageEntity to set
     */
    public void setUnstructuredContentPageEntity(UnstructuredContentPageEntity unstructuredContentPage) {
        this.unstructuredContentPage = unstructuredContentPage;
    }
}
